<template>
	<view class="container">
		<view class="activity-head">
			<image class="item-bg" src="../../../static/images/img_activity_bg.png" mode="aspectFill"></image>
			<view class="item-body">
				<image class="thumb" :src="detail.image_text" mode="aspectFill"></image>
				<view class="content">
					<view class="title">{{detail.name}}</view>
					<view class="price"><text>¥{{detail.salesprice}}</text>/人</view>
					<!-- #ifdef MP-WEIXIN -->
					<button open-type="share" class="share-box">
						<image class="share" src="../../../static/icons/icon_share.png" mode="aspectFit"></image>
					</button>
					<!-- #endif -->
					
				</view>
			</view>
		</view>
		<view class="activity-wrap">
			<view class="title-box">精彩瞬间</view>
			<scroll-view class="scroll-box" scroll-x="true" >
				<image @click="bindPrev(index)" v-for="(item,index) in detail.images" :src="item" mode="aspectFill"></image>
				
			</scroll-view>
		</view>
		<view class="activity-wrap">
			<view class="title-box">活动详情</view>
			<view class="editor-box">
				<u-parse :html="content"></u-parse>
			</view>
		</view>
		<block v-if="detail.active_status == 1">
		<view class="wd-flex wd-buttonbar" v-if="detail.join_status==0">
			<view class="wd-flex-cell" >
				<u-button :custom-style="wd_button_primary" shape="circle" :ripple="true" @click="href">参加活动</u-button>
			</view>
		</view>
		<view class="wd-flex wd-buttonbar" v-if="detail.join_status==1">
			<view class="wd-flex-cell" >
				<u-button :custom-style="wd_button_primary" shape="circle" :ripple="true">已参与活动</u-button>
			</view>
		</view>
		</block>
		<block v-else>
			<view class="wd-flex wd-buttonbar" >
				<view class="wd-flex-cell">
					<u-button :custom-style="wd_button_plain" shape="circle" :ripple="true" :plain="true">{{detail.active_status==2?"活动进行中":"活动已结束"}}</u-button>
				</view>
			</view>
		</block>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				active_id:0,
				detail:{},
				content: ''
			}
		},
		onLoad(options){
			if(options.active_id){
				this.active_id = options.active_id;
				this.getDetail();
			}
		},
		onShareAppMessage() {
			let user = this.$core.getUserinfo();
			let path = '/pages/activity/activityDetail/activityDetail?active_id=' + this.detail.id
			if(user){
				path += '&pid='+user.id;
			}
			return {
			    title: this.detail.name,
			    path: path,
			    imageUrl: this.detail.image || '',
			}
		},
		onShareTimeline() {
			let query = 'active_id='+this.detail.id
			let user = this.$core.getUserinfo();
			if(user){
				query += '&pid='+user.id;
			}
			return {
			    title: this.detail.name,
				query: query
			}
		},
		methods: {
			getDetail(){
				var that = this;
				var active_id = that.active_id;
				that.$core.get({url:'fitness.active/detail',data:{active_id:active_id},success:(ret)=>{
					that.detail = ret.data;
					that.content = ret.data.content
				}});
			},
			
			href() {
				if(!this.$core.getUserinfo(true)){
					return '';
				}
				this.$utils.href('/pages/activity/activityOrder/activityOrder?active_id='+this.active_id)
			},
			bindPrev(index){
				uni.previewImage({
					urls: this.detail.images,
					current: index
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.activity-head {
		position: relative;
		height: 520rpx;

		.item-bg {
			display: block;
			width: 100%;
			height: 390rpx;
			filter: blur(20px);
		}

		.item-body {
			position: absolute;
			left: 0;
			right: 0;
			bottom: 0;
			display: flex;
			padding: 0 24rpx;
			height: 150rpx;
			background-color: #FFFFFF;
			border-radius: 20rpx 20rpx 0 0;

			.thumb {
				display: block;
				margin-top: -180rpx;
				margin-right: 48rpx;
				width: 220rpx;
				height: 290rpx;
				border-radius: 12rpx;
			}

			.content {
				position: relative;
				flex: 1;
				margin-top: -180rpx;
			}

			.title {
				height: 180rpx;
				line-height: 50rpx;
				font-size: 36rpx;
				color: #FFFFFF;
				font-weight: 500;
				letter-spacing: 2rpx;
			}

			.price {
				margin-top: 36rpx;
				margin-right: 60rpx;
				line-height: 40rpx;
				font-size: 28rpx;
				color: #ABABAC;

				text {
					line-height: 50rpx;
					font-size: 44rpx;
					color: #000000;
					font-weight: bold;
				}
			}
			
			
			.share-box {
				position: absolute;
				right: 0;
				top: 220rpx;
				display: block;
				width: 40rpx;
				height: 40rpx;
				padding: 0;
				background: transparent;
				&::after {
					display: none;
				}
			}
			
			.share {
				display: block;
				width: 40rpx;
				height: 40rpx;
			}
		}
	}
	.activity-wrap {
		padding: 26rpx 24rpx;
		background-color: #FFFFFF;
		
		.title-box {
			line-height: 40rpx;
			font-size: 28rpx;
			color: #000000;
		}
		
		.scroll-box {
			margin-top: 18rpx;
			font-size: 0;
			white-space: nowrap;
			
			image {
				display: inline-block;
				margin-right: 16rpx;
				width: 250rpx;
				height: 170rpx;
				border-radius: 20rpx;
				
				&:last-child {
					margin-right: 0;
				}
			}
		}
		
		.editor-box {
			margin-top: 16rpx;
			padding-top: 16rpx;
			padding-bottom: 190rpx;
			border-top: 1rpx #EEEEEE solid;
			line-height: 48rpx;
			font-size: 28rpx;
			color: #333333;
		}
	}
</style>